#include "hashTable.h"

namespace bucketHash
{
	template <class K, class V, class Hash = hash<K>>
	class unordered_map
	{
		struct MapKeyOfT
		{
			const K& operator()(const pair<const K, V>& kv)
			{
				return kv.first;
			}
		};
	public:
		typedef typename hashTable<K, pair<const K, V>, Hash, MapKeyOfT>::iterator iterator;

		iterator begin()
		{
			return _ht.begin();
		}

		iterator end()
		{
			return _ht.end();
		}

		V& operator[](const K& key)
		{
			return (insert(make_pair(key, V())).first)->second;
		}

		pair<iterator, bool> insert(const pair<const K, V>& kv)
		{
			return _ht.insert(kv);
		}

		bool erase(const K& key)
		{
			return _ht.erase(key);
		}

	private:
		hashTable<K, pair<const K, V>, Hash, MapKeyOfT> _ht;
	};
}